from exts import db


# orm模型
class C1(db.Model):
    __tablename__ = "c1"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    cultural_relic_number = db.Column(db.String(45), nullable=False)
    ornamentation = db.Column(db.String(45), nullable=False)
    type = db.Column(db.String(45), nullable=False)
    color = db.Column(db.String(45), nullable=False)
    surface_weathering = db.Column(db.String(45), nullable=False)


class C1_1(db.Model):
    __tablename__ = "c1_1"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    cultural_relic_number = db.Column(db.String(45), nullable=False)
    ornamentation = db.Column(db.String(45), nullable=False)
    type = db.Column(db.String(45), nullable=False)
    color = db.Column(db.String(45), nullable=False)
    surface_weathering = db.Column(db.String(45), nullable=False)


class C2(db.Model):
    __tablename__ = "c2"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    cultural_relics_sampling_point = db.Column(db.String(45), nullable=False)
    SiO2 = db.Column(db.String(45), nullable=False)
    Na2O = db.Column(db.String(45), nullable=False)
    K2O = db.Column(db.String(45), nullable=False)
    CaO = db.Column(db.String(45), nullable=False)
    MgO = db.Column(db.String(45), nullable=False)
    Al2O3 = db.Column(db.String(45), nullable=False)
    Fe2O3 = db.Column(db.String(45), nullable=False)
    CuO = db.Column(db.String(45), nullable=False)
    PbO = db.Column(db.String(45), nullable=False)
    BaO = db.Column(db.String(45), nullable=False)
    P2O5 = db.Column(db.String(45), nullable=False)
    SrO = db.Column(db.String(45), nullable=False)
    SnO2 = db.Column(db.String(45), nullable=False)
    SO2 = db.Column(db.String(45), nullable=False)

    # 外键
    id_c1 = db.Column(db.Integer, db.ForeignKey("c1.id"))
    c1 = db.relationship("C1", backref="c2_s")


class C2_2(db.Model):
    __tablename__ = "c2_2"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    cultural_relics_sampling_point = db.Column(db.String(45), nullable=False)
    SiO2 = db.Column(db.String(45), nullable=False)
    Na2O = db.Column(db.String(45), nullable=False)
    K2O = db.Column(db.String(45), nullable=False)
    CaO = db.Column(db.String(45), nullable=False)
    MgO = db.Column(db.String(45), nullable=False)
    Al2O3 = db.Column(db.String(45), nullable=False)
    Fe2O3 = db.Column(db.String(45), nullable=False)
    CuO = db.Column(db.String(45), nullable=False)
    PbO = db.Column(db.String(45), nullable=False)
    BaO = db.Column(db.String(45), nullable=False)
    P2O5 = db.Column(db.String(45), nullable=False)
    SrO = db.Column(db.String(45), nullable=False)
    SnO2 = db.Column(db.String(45), nullable=False)
    SO2 = db.Column(db.String(45), nullable=False)

    # 外键
    id_c1_1 = db.Column(db.Integer, db.ForeignKey("c1_1.id"))
    c1_1 = db.relationship("C1_1", backref="c2_2_s")


class C3(db.Model):
    __tablename__ = "c3"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    cultural_relic_number = db.Column(db.String(45), nullable=False)
    surface_weathering = db.Column(db.String(45), nullable=False)
    SiO2 = db.Column(db.String(45), nullable=False)
    Na2O = db.Column(db.String(45), nullable=False)
    K2O = db.Column(db.String(45), nullable=False)
    CaO = db.Column(db.String(45), nullable=False)
    MgO = db.Column(db.String(45), nullable=False)
    Al2O3 = db.Column(db.String(45), nullable=False)
    Fe2O3 = db.Column(db.String(45), nullable=False)
    CuO = db.Column(db.String(45), nullable=False)
    PbO = db.Column(db.String(45), nullable=False)
    BaO = db.Column(db.String(45), nullable=False)
    P2O5 = db.Column(db.String(45), nullable=False)
    SrO = db.Column(db.String(45), nullable=False)
    SnO2 = db.Column(db.String(45), nullable=False)
    SO2 = db.Column(db.String(45), nullable=False)
